/*
 * @Description:大厅
 * @Author: maskMan
 * @LastEditTime: 2024-10-21 09:09:27
 */
import CacheStorage from '../general/cacheStore'
import Config from '../general/config'
import resManager from '../general/resManager'
import { tips } from '../general/shorts'
import { util } from '../general/util'
import GameInstance from './gameInstance'
const { ccclass, property } = cc._decorator
@ccclass
export default class Hall extends cc.Component {
  _isRuning = false
  static instance: Hall
  gameInstance: GameInstance
  user: IUserInfo
  trainRecord: IUserScore[] = []
  haveRecord: boolean = false
  onLoad() {
    Hall.instance = this
    this._createUser()
  }
  public isBlockIng(): boolean {
    if (this._isRuning) {
      tips('请不要操作太频繁')
      return false
    }
    this._isRuning = true
    this.scheduleOnce(() => {
      this._isRuning = false
    }, 0.2)
    return true
  }
  /**初始化创建训练用户信息 */
  private _createUser() {
    const result = CacheStorage.getUserData('888')
    if (!result) {
      this.user = {
        uid: Config.uid,
        realName: null,
        age: null,
        sex: null
      }
      this.gameInstance = new GameInstance()
      this.gameInstance.user = this.user
      CacheStorage.setUserData(`${this.user.uid}`, this.user)
    }
  }
}
